home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c++
- Subject: Re: passing struct to constructor - temp.txt [1/1]
- Date: Fri, 02 Feb 1996 14:46:02 +0200
- Organization: Carelcomp Forest
- Message-ID: <3112078A.1626@cmt.lpr.mail.carel.fi>
- References: <4eqgq3$5g1@geraldo.cc.utexas.edu>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (WinNT; I)
-
- W. Harris wrote:
- >
- > The compiler error I'm getting is "VIN is not a member of struct1". The
- > code has been severely minimized, however this should have the bare
- > essentials required to solve the problem.
- >
- > class CarData
- > {
- > private :
- >
- > char VIN[7];
- >
- > public :
- >
- > CarData(struct astruct1 CarInf);
- >
- > };
- > //********************************************************
- >
- > CarData::CarData(struct astruct1 CarInf)
- > {
- > strcpy(VIN,CarInf.VIN);
- > }
- >
- > struct astruct1
- > {
- > char VIN[7];
- > }CarInfo;
-
- You'd want to define the struct:
-
- struct astrcut1 {
- char VIN[7];
- };
-
- before the definition of CarData. Here you'd just declare the instance:
-
- astruct1 CarInfo;
-
- Also, bear in mind that in C++, struct behaves exactly as a class. The only difference is
- that in a class, members are private by default, and in a struct, they default to public.
-
- >
- > void main()
- > {
- >
- > CarData CarConst1(struct astruct1 CarInfo);
- > }
-
- Later,
- AriL
- --
- All my opinions are mine and mine alone.
-